<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\UserGroup;
use yii\helpers\ArrayHelper;

/* @var $this yii\web\View */
/* @var $model common\models\User */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="box-body">
    <h2>会员基本信息</h2>
    <?php $form = ActiveForm::begin([
        'options'=>['class'=>'form-horizontal'],
        'fieldConfig'=>[
            'template'=>"{label}\n<div class=\"col-sm-10\">{input}\n{hint}\n{error}</div>",
            'labelOptions'=>['class'=>'col-sm-2 control-label'],
        ],
    ]); ?>
    
    <?= $form->field($model, 'money')->textInput(['maxlength' => true]) ?>
    
    <?= $form->field($model, 'username')->textInput(['maxlength' => true]) ?>
    
    <?= $form->field($model, 'realname')->textInput(['maxlength' => true]) ?>
    
    <?= $form->field($model, 'sex')->dropDownList(['1' => '男', '2'=>'女']) ?>
    
    <?= $form->field($model, 'group_id')->dropDownList(ArrayHelper::map(UserGroup::findList(), 'group_id', 'group_name')) ?>
    
    <?= $form->field($model, 'age')->textInput() ?>
    
    <?= $form->field($model, 'birthday')->textInput(['maxlength' => true]) ?>
    
    <?= $form->field($model, 'mobile')->textInput(['maxlength' => true]) ?>
    
    <?= $form->field($model, 'idcard')->textInput(['maxlength' => true]) ?>
    
    <?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
    

    <div class="box-footer">
        <a href="javascript:history.back();" class="btn btn-default">取消</a>
        <?= Html::submitButton($model->isNewRecord ? '创建' : '更新', ['class' => $model->isNewRecord ? 'btn btn-success pull-right' : 'btn btn-primary pull-right']) ?>
    </div>
    
    <?php ActiveForm::end(); ?>

</div>
<?php
if(!$model->isNewRecord){
    ?>
    <div class="box-body">
        <h2>会员病史</h2>
        
        <?php $form = ActiveForm::begin([
            'options' => ['class' => 'form-horizontal'],
            'fieldConfig' => [
                'template' => "{label}\n<div class=\"col-sm-10\">{input}\n{hint}\n{error}</div>",
                'labelOptions' => ['class' => 'col-sm-2 control-label'],
            ],
        ]); ?>
        
        <?php $case = $model->userCase ?>
        
        <?= $form->field($case, 'user_id')->hiddenInput()->label(false) ?>
        
        <?= $form->field($case, 'diagnosis')->textInput(['maxlength' => true]) ?>
        
        <?= $form->field($case, 'sick_time')->textInput(['maxlength' => true]) ?>
        
        <?= $form->field($case, 'medical_history')->textInput(['maxlength' => true]) ?>
        
        <?= $form->field($case, 'irritability_history')->textInput() ?>
        
        <?= $form->field($case, 'family_history')->textInput(['maxlength' => true]) ?>
        
        <?= $form->field($case, 'hobby')->textInput(['maxlength' => true]) ?>
        
        <?= $form->field($case, 'address')->textInput(['maxlength' => true]) ?>


        <div class="box-footer">
            <a href="javascript:history.back();" class="btn btn-default">取消</a>
            <?= Html::submitButton($model->isNewRecord ? '创建' : '更新', ['class' => $model->isNewRecord ? 'btn btn-success pull-right' : 'btn btn-primary pull-right']) ?>
        </div>
        
        <?php ActiveForm::end(); ?>

    </div>

    <div class="box-body">
        <h2>受托人信息</h2>
        
        <?php $form = ActiveForm::begin([
            'options' => ['class' => 'form-horizontal'],
            'fieldConfig' => [
                'template' => "{label}\n<div class=\"col-sm-10\">{input}\n{hint}\n{error}</div>",
                'labelOptions' => ['class' => 'col-sm-2 control-label'],
            ],
        ]); ?>
        
        <?php $consignee = $model->consignee ?>
        
        <?= $form->field($consignee, 'user_id')->hiddenInput()->label(false) ?>
        <?= $form->field($consignee, 'relation')->textInput(['maxlength' => true]) ?>
        
        <?= $form->field($consignee, 'realname')->textInput(['maxlength' => true]) ?>
        
        <?= $form->field($consignee, 'mobile')->textInput(['maxlength' => true]) ?>
        
        <?= $form->field($consignee, 'sex')->dropDownList(['1' => '男', '2' => '女']) ?>
        
        <?= $form->field($consignee, 'idcard')->dropDownList(ArrayHelper::map(UserGroup::findList(), 'group_id', 'group_name')) ?>
        
        <?= $form->field($consignee, 'wechat_name')->textInput() ?>
        
        <?= $form->field($consignee, 'email')->textInput(['maxlength' => true]) ?>
        
        <?= $form->field($consignee, 'address')->textInput(['maxlength' => true]) ?>


        <div class="box-footer">
            <a href="javascript:history.back();" class="btn btn-default">取消</a>
            <?= Html::submitButton($model->isNewRecord ? '创建' : '更新', ['class' => $model->isNewRecord ? 'btn btn-success pull-right' : 'btn btn-primary pull-right']) ?>
        </div>
        
        <?php ActiveForm::end(); ?>

    </div>
    <?php
}
?>